﻿#pragma once

#ifndef MYCLICKLABEL_H
#define MYCLICKLABEL_H
#include <QWidget>
#include <QLabel>
#include <QObject>
#include <QEvent>
#include <QMouseEvent>


class myLabel : public QLabel
{
    Q_OBJECT    // must include this if you use Qt signals/slots
public:
    explicit myLabel(QWidget* parent = 0);
    void setImage(QImage src);
signals:
    void signal_updataZoom(float value);
    void signal_updataPos(QPointF pos);
private:
    void Init();
    void mousePressEvent(QMouseEvent* event); //鼠标按下
    void mouseReleaseEvent(QMouseEvent* event);//鼠标释放
    void mouseMoveEvent(QMouseEvent* event);//鼠标移动
    void mouseDoubleClickEvent(QMouseEvent* event);// 鼠标双击事件
    void wheelEvent(QWheelEvent* event);
    void paintEvent(QPaintEvent* event) override;
    void onZoomInImage(void);
    void onZoomOutImage(void);
	// 返回鼠标对应显示区域坐标
    QPointF convertMouse2LogicalDraw(const QPointF& ptInMouse);
    QPointF convertLogicalDraw2Mouse(const QPointF& ptInDraw);
	// 将鼠标点击显示区域的坐标转换为图像上像素坐标返回
    QPointF convertLogicalDraw2Pixcel(const QPointF& ptInDraw);
    QPointF convertPixcel2LogicalDraw(const QPointF& ptInPixcel);
private:
    QImage m_ImageQ;
    float m_ScaleX;
    float m_ScaleY;
    float m_XPtInterval;
    float m_YPtInterval;
    float m_ZoomValue;
    QPointF m_mousePos;
    QVector<float> m_xInDraw;
    QVector<float> m_yInDraw;
    QRectF m_windowsPos;
    QPoint                              m_OldPos;
    bool m_Pressed;
    float m_ZoomDafault;
    bool m_isFirstWheel;
    QPointF m_lastWheelPos;
    float m_zoomValueOri;
    QPointF m_drawPoint;
};

#endif // MYCLICKLABEL_H